<%-- 
    Document   : formSearchProduct
    Created on : Jun 12, 2011, 1:05:09 PM
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>

        <!-- link add product -->
        <c:if test="${sessionScope.user.role == 'admin'}">
            <div align="right">
                <a href="Product.do?action=formAddProduct"> Add product </a>
            </div>
        </c:if>

        <h2> LIST PRODUCT </h2>

        <!-- form searchByName -->
        <form method="POST" action="Product.do?action=searchByName">
            By Name: <input type="text" name="txtKeyword" value="${requestScope.keyword}"/>
            <input type="submit" value="Search"/>
        </form>

        <!-- link searchByAlphabet -->
        <div>
            By Alphabet:
            <a href="Product.do?action=searchByAlphabet&range=A-E"> A -> E </a>
            &nbsp; | &nbsp;
            <a href="Product.do?action=searchByAlphabet&range=F-J"> F -> J </a>
            &nbsp; | &nbsp;
            <a href="Product.do?action=searchByAlphabet&range=K-O"> K -> O </a>
            &nbsp; | &nbsp;
            <a href="Product.do?action=searchByAlphabet&range=P-T"> P -> T </a>
            &nbsp; | &nbsp;
            <a href="Product.do?action=searchByAlphabet&range=U-Z"> U -> Z </a>
        </div> <br/>

        <!-- list books -->
        <table border="1">
            <tr>
                <th> ID </th>
                <th> Name </th>
                <th> Description </th>
                <th> Price </th>
            </tr>
            <c:forEach var="product" items="${requestScope.products}">
            <tr>
                <td> ${product.id} </td>
                <td> ${product.name} </td>
                <td> ${product.description} </td>
                <td> ${product.price} </td>
            </tr>
            </c:forEach>
        </table>
    </body>
</html>
